var Dog=require("./dog.js");
var dog1=new Dog("taidi",5);
var dog2=new Dog("zangao",9);
dog1.on("bark",()=>{
    dog1.bark();
})
dog2.on("bark",()=>{
    dog2.bark();
})

var start=setInterval(()=>{
    dog1.energy=dog1.energy-1;
    dog2.energy=dog2.energy-1;
    dog1.emit("bark");
    dog2.emit("bark");
    if(dog1.energy==0){
        clearInterval(start);
    }
},1000);
